<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>方法</title>
    <script src="./vue.js"></script>
</head>
<body>
<div id="app">
    {{fullName}}
</div>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            firstName: 'lin',
            lastName: 'yi cong'
        },
        computed: {
            fullName: {
                get: function () {
                    console.log("计算了一次");
                    return this.firstName + " " + this.lastName;
                },
                set: function (value) {
                    var arr = value.split(" ");
                    this.firstName = arr[0];
                    this.lastName = arr[1] + ' ' + arr[2];
                    console.log("setter: " + value);
                }
            }
        }
    });
</script>
</body>
</html>